using System;
using System.Collections.Generic;
using System.Text;

namespace Spacedash.Logic
{
    /// <summary>
    /// Structure that holds information of a finished lap: Number of lap and lap time
    /// </summary>
    public struct Lap
    {
        /// <summary>
        /// Lap number (Zero-based)
        /// </summary>
        public int lapNumber;
        /// <summary>
        /// Time that took to finish this lap in milliseconds
        /// </summary>
        public long time;
        /// <summary>
        /// Constructor. Inits values.
        /// </summary>
        /// <param name="lapNumber">Lap number</param>
        /// <param name="time">Lap time</param>
        public Lap(int lapNumber, long time)
        {
            this.lapNumber = lapNumber;
            this.time = time;
        }
        /// <summary>
        /// \internal Formats the lap data to a string
        /// </summary>
        /// <returns>Lap data in format LAP - MINUTES:SECONDS:MILLISECONDS</returns>
        public override string ToString()
        {
            TimeSpan t = TimeSpan.FromMilliseconds(time);
            return String.Format("{0} - {1:00}:{2:00}:{3:00}",lapNumber+1,t.Minutes,t.Seconds,t.Milliseconds);
        }
    }
}
